Field of the Invention
The present disclosure generally relates to image processing and, more particularly, to an image processing apparatus, method, and storage medium for determining a degree of similarity between a target pixel and a reference pixel in image data.
Description of the Related Art
In an image processing technique, matching methods for determining whether patterns of pixels included in two regions are similar to each other, such as template matching and block matching, have been used. These methods for matching regions are used not only for motion compensation, positioning, and estimation of an optical flow but also for a noise reduction process, for example. Japanese Translation Patent Publication PCT No. 2007-536662 and Japanese Patent Laid-Open No. 2011-39675 disclose methods for performing noise reduction processes in accordance with a degree of similarity between a target pixel and a reference pixel. Specifically, a degree of similarity of a reference pixel relative to a target pixel is calculated by matching between a region including the target pixel and a region including the reference pixel, and a noise reduction process is performed on a pixel value of the target pixel by performing weighted average in accordance with the degree of similarity.
As a degree of similarity, a sum of squared difference (SSD) or a sum of absolute difference (SAD) which is calculated using pixel values of pixels corresponding to each other are widely used. Specifically, by calculating differences between values of pixels corresponding to each other in different regions, a degree of similarity between the regions is calculated. The calculation of the degree of similarity between regions with high accuracy is important for improving effect of objects of various image processes. Note that a method for calculating a degree of similarity using the SSD is disclosed in Japanese Patent Laid-Open No. 10-289315.
In general, damage (defect) may be generated in some pixels in an image pickup element, such as a charge-coupled device (CCD) sensor or a complementary metal-oxide semiconductor (CMOS) sensor, during a fabrication process or the like. As a result, such pixels output pixel values of abnormal levels in image data obtained through image capturing (hereinafter referred to as “defective pixels”). In recent years, some image pickup elements include pixels for specific purposes (an image surface phase difference pixel, a pixel for ranging, and the like) other than purpose of image capturing in an image pickup region. Accordingly, some pixels which may not obtain pixel values in a condition the same as that for other neighboring pixels may be included in an image pickup element. In general, most of the pixels having pixel values recognized as abnormal values are corrected by image processing in the image pickup apparatus. However, pixel values which have been corrected do not represent pixel values obtained as a result of image capturing performed on a target object. Therefore, when a degree of similarity between regions in image data is to be calculated, if defective pixels or pixels for specific purposes are detected, the degree of similarity may not be reliably calculated. Furthermore, there arises the same problem in washed-out (white) pixels and blocked-up shadows (black) pixels which exceed limit of a dynamic range since reliable pixel values are not obtained.